﻿Public Class ActivityMessage
    Inherits MessageBase

    Public Property Timestamp As Date?
    Public Property TotalTimerTime As Decimal?
    Public Property NumSession As Integer?
    Public Property Type As ActivityEnum?
    Public Property [Event] As EventEnum?
    Public Property EventType As EventTypeEnum?
    Public Property LocalTimestamp As Date?
    Public Property EventGroup As Integer?

    Protected Overrides Sub Populate(reader As System.IO.BinaryReader, Definition As DefinitionMessage)
        For Each FieldDef As FieldDefinition In Definition.Fields
            Select Case FieldDef.FieldDefinitionNumber
                Case 253 ' Timestamp
                    Timestamp = FitHelper.TranslateDateTime(reader.ReadUInt32)
                Case 0
                    TotalTimerTime = reader.ReadUInt32
                Case 1
                    NumSession = reader.ReadUInt16
                Case 2
                    Type = CType(reader.ReadByte, ActivityEnum)
                Case 3
                    [Event] = CType(reader.ReadByte, EventEnum)
                Case 4
                    EventType = CType(reader.ReadByte, EventTypeEnum)
                Case 5
                    LocalTimestamp = FitHelper.TranslateDateTime(reader.ReadUInt32)
                Case 6
                    EventGroup = reader.ReadByte
                Case Else
                    FitHelper.ReadUnknownField(reader, FieldDef)
            End Select
        Next
    End Sub
End Class
